package com.bltec.emergency.mapper;

import com.bltec.emergency.model.Plan;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
@Mapper
public interface PlanMapper {
    //插入一条Plan记录
    @Insert("insert into plan (name,record_info,plan_level,plan_type,file_url," +
            "create_by,create_time,enable) " +
            "values(#{name},#{recordInfo},#{planLevel},#{planType},#{fileUrl},#{createBy},#{createTime},#{enable})")
    boolean insert(Plan Plan);

    //通过id设置一条记录为不可用
    @Update("update plan set enable=0 where id=#{id}")
    boolean setDisableById(Long id);

    //通过id更新一条记录
    @Update("update plan set name=#{name},record_info=#{recordInfo},plan_level=#{planLevel},plan_type=#{planType}," +
            "file_url=#{fileUrl},update_by=#{updateBy},update_time=#{updateTime} where id=#{id}")
    boolean updatePlanById(Plan Plan);

    //查找符合id字段的记录
    @Select("select id,name,record_info,plan_level,plan_type,file_url,create_by,create_time,update_by,update_time,enable" +
            " from plan where id =#{id} and enable=1")
    Plan getPlanById(Long id);

    //查找所有记录
    @Select("select id,name,record_info,plan_level,plan_type,file_url,create_by,create_time,update_by,update_time,enable" +
            " from plan where enable=1")
    List<Plan> selectAll();
}